1. Field of the Invention
The present invention relates to a graphics data processing technique such as computer graphics, and particularly, to a method of and an apparatus for processing graphics data and drawing lines with antialiasing.
2. Description of the Prior Art
FIG. 1 shows a straight line drawn from coordinates (X0, Y0) to coordinates (X1, Y1) by a digital differential analyzer (DDA) according to a prior art. In the figure, an abscissa corresponds to an X-axis, an ordinate to a Y-axis, dotted grid lines to coordinate lines, and each hatched square to a pixel. The straight line is formed by plotting pixels 1 to 12 in this order.
A known algorithm used to draw a straight line of this kind is Bresenham algorithm. FIG. 2 shows a C-language-like description of the Bresenham algorithm for drawing the straight line of FIG. 1.
In FIG. 2, Step S111 starts to draw the line. Step S112 sets a variation in X. Step S113 sets a variation in Y. Step S114 sets a unit variation in Y with respect to X.
Step S115 sets an initial X-coordinate. Step S11B sets an initial Y-coordinate. Step S117 sets an initial value of 0.5 for a distance dM from a pixel center to the center of the line. Step S118 sets an intensity I for each pixel.
Then, the line is generated. Namely, step S119 increments X from X0 to X1. During this incremental operation, step S120 plots a pixel at coordinates (X, Y) with the intensity I, step S121 accumulates delta-Y as dM, and step S122 checks to see if dM&gt;1. If dM&gt;1, step S123 increments Y by +1 and step S124 resets dM.
The Bresenham algorithm is easy to implement with the DDA.
The straight line drawn according to the Bresenham algorithm, however, involves stepwise jaggy, if the line is diagonal as shown in FIG. 1. A technique of removing such jaggy is antialiasing. A method of carrying out antialiasing on a straight line is disclosed in, for example, "Filtering Edges for Gray-Scale Displays" by Gupta Sproull, Computer Graphics, Vol. 15, No. 3, August, 1981.
Generally, the DDA draws a straight line pixel by pixel as shown in FIG. 1. Instead, the technique disclosed in the above document draws a straight line with three shaded pixels at a time. Namely, the technique provides a straight line with a width of three pixels with the central one having a higher intensity value and boundary ones having lower intensity values. As a result, intensity differences along the boundaries of the straight line become less distinct, thereby removing jaggy as shown in FIG. 3A.
In FIG. 3A, a straight line TA is drawn from coordinates (Xa1, Ya1) to coordinates (Xa2, Ya2), and a straight line TB from (Xb1, Yb1) to (Xb2, Yb2) with each straight line being oblique. Pixels used to draw the line TA are represented with squares as shown in FIG. 3B, and those for the line TB with circles as shown in the same figure. Each pixel may have any one of five intensity values as shown in FIG. 3C. A number depicted in a given pixel in FIG. 3A indicates drawing order. Pixels having the same number with or without quotation marks are simultaneously drawn. For example, pixels 1, 1', and 1" are drawn at the same time with different intensity values.
FIG. 4 shows a graphics data processor according to a prior art, for drawing straight lines such as those shown in FIGS. 1 and 3A.
The processor has a microprocessor unit (MPU) 111 for providing parameters of a straight line to draw, a digital differential analyzer (DDA) 112 for generating the straight line according to antialiasing conditions, a frame buffer (VRAM) 113 for storing the straight line, a CRT 114 for displaying the straight line read out of the frame buffer 113, and a CRT controller 115 for controlling the CRT 114.
When drawing a plurality of straight lines, the antialiasing technique disclosed in the document mentioned above raises a problem. This problem will be explained with reference to FIG. 5.
In FIG. 5, a straight line TA is drawn first, and then, a straight line TB is drawn close to the line TA so that antialiasing pixels of the lines TA and TB overlap each other. The shapes and intensity values of the pixels of FIG. 5 are the same as those of FIGS. 3B and 3C.
In FIG. 5, pixels of the lines TA and TB overlap one another in a zone P surrounded with a thick line. Since the line TB is drawn after the line TA, the pixels of the line TB in the zone P are drawn over the corresponding pixels of the line TA. If the intensity difference between the pixels of the lines TA and TB in the zone P is large, the antialiasing will be incorrect and provide unnatural images of the lines TA and TB in the zone P.
For example, if a shaded pixel B3" of the line TB is darker than a shaded pixel A2' of the line TA on which the pixel B3" is drawn, the lines TA and TB will show unnatural images at there. This problem also occurs on lines that cross each other.